import { AddressItem } from "../type/addressTypes"
import { ResponseType } from "../type/response"
import request from "../utils/request"

enum Enum {
  fetchAddressListAPI = "/userAddress/findUserAddress",
  addAddressAPI = "/userAddress/save",
  findAddressDetailAPI = "/userAddress",
  updateAddressAPI = "/userAddress/update",
  deleteAddressAPI = "/userAddress/delete"
}

/**
 * @description 获取收货地址列表接口
 */
export const fetchAddressListAPI = () => request.get<ResponseType<AddressItem[]>>(Enum.fetchAddressListAPI)

/**
* @description 新增收货地址接口
*/
export const addAddressAPI = (data: AddressItem) => request.post<ResponseType<null>>(Enum.addAddressAPI, data)

/**
* @description 获取收货地址详情接口
*/
export const findAddressDetailAPI = (id: string) => request.get<ResponseType<AddressItem>>(`${Enum.findAddressDetailAPI}/${id}`)

/**
* @description 更新收货地址接口
*/
export const updateAddressAPI = (data: AddressItem) => request.post<ResponseType<null>>(Enum.updateAddressAPI, data)

/**
* @description 删除收货地址接口
*/
export const deleteAddressAPI = (id: string) => request.get<ResponseType<null>>(`${Enum.deleteAddressAPI}/${id}`)